#let me write from my heart

inp = input("Введите скобочную последовательность: ")

def return_result(res):
    print(res)
    exit(0)

required_closers = []
for i in range(len(inp)):
    char = inp[i]
    
    if (char == "("):
        required_closers.append(")")
    elif (char == "["):
        required_closers.append("]")
    elif (char == "{"):
        required_closers.append("}")
    
    if (char == ")" or char == "]" or char == "}"):
        if (len(required_closers) > 0 and required_closers[-1] == char):
            required_closers.pop(-1)
        else:
            return_result(False)

if (len(required_closers) > 0):
    return_result(False)
else:
    return_result(True)
